﻿<UserControl
    x:Class="Srk.BetaseriesApiApp.Views.Comments"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="60" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="60" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock Text="Show: " Grid.Row="0" Grid.Column="0" Margin="0,4,8,2" HorizontalAlignment="Right" />
        <TextBlock Text="Season: " Grid.Row="1" Grid.Column="0" Margin="0,4,8,2" HorizontalAlignment="Right" />
        <TextBlock Text="Episode: " Grid.Row="1" Grid.Column="2" Margin="0,4,8,2" HorizontalAlignment="Right" />
        <TextBlock Text="Member: " Grid.Row="2" Grid.Column="0" Margin="0,4,8,2" HorizontalAlignment="Right" />
        <!--<TextBlock Text="Write a comment: " Grid.Row="3" Grid.Column="0" Margin="0,4,8,2" HorizontalAlignment="Right" />-->

        <TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" Margin="4"
                             Text="{Binding MyShow, UpdateSourceTrigger=PropertyChanged}" />
        <TextBox Grid.Row="1" Grid.Column="1" Margin="4"
                             Text="{Binding MySeason, UpdateSourceTrigger=PropertyChanged}" />
        <TextBox Grid.Row="1" Grid.Column="3" Margin="4"
                             Text="{Binding MyEpisodeNB, UpdateSourceTrigger=PropertyChanged}" />
        <TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Margin="4"
                             Text="{Binding MemberLogin, UpdateSourceTrigger=PropertyChanged}" />
        <TextBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Grid.RowSpan="2" Margin="4"
                             AcceptsReturn="True" VerticalScrollBarVisibility="Visible"
                             Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged}" />

        <!--<TextBlock Margin="7.706,8,1.097,8" Grid.Row="3" TextWrapping="Wrap" Text="Member"/>
                    <TextBox Grid.ColumnSpan="3" Grid.Column="1" Margin="8" Grid.Row="3" TextWrapping="Wrap" Text="{Binding MemberLogin}"/>
                    <Button Content="Fetch member comments" Grid.Column="4" Margin="8" Grid.Row="3" RenderTransformOrigin="0.516,0.484" Command="{Binding GetMemberCommentsCommand}"/>-->

        <Button Grid.Column="4" Grid.Row="0" Margin="4" Content="Fetch show comments"
                            Command="{Binding SearchShowCommentCommand}" />
        <Button Grid.Column="4" Grid.Row="1" Margin="4" Content="Fetch episode comments"
                            Command="{Binding SearchCommand}" />
        <Button Grid.Column="4" Grid.Row="2" Margin="4" Content="Fetch member comments"
                            Command="{Binding GetMemberCommentsCommand}" />
        <Button Grid.Row="3" Grid.Column="4" Margin="4" Content="Comment on show"
                            Command="{Binding CommentShowCommand}" />
        <Button Grid.Row="4" Grid.Column="4" Margin="4" Content="Comment on episode"
                            Command="{Binding CommentEpisodeCommand}" />
        <Button Grid.Row="5" Grid.Column="4" Margin="4" Content="Comment on member"
                            Command="{Binding CommentMemberCommand}" />

        <StackPanel Grid.Row="5" Grid.ColumnSpan="4" Orientation="Horizontal">
            <TextBlock xml:space="preserve"><Run Text="Comment in reply to comment: "/></TextBlock>
            <TextBlock Text="{Binding SelectedComment.InnerId, FallbackValue=None, TargetNullValue=None}" />
            <Button Content="x" Command="{Binding ClearReplyCommand}" Margin="4,0" Padding="2,0" Height="16" FontSize="8" />
        </StackPanel>

        <ListView Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="6" Margin="8"
                              ItemsSource="{Binding MyComments}"
                              SelectedItem="{Binding SelectedComment, Mode=OneWayToSource}"
                              x:Name="lvComments">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Posted date"
                                                DisplayMemberBinding="{Binding Postdate}" />
                    <GridViewColumn Header="ID"
                                                DisplayMemberBinding="{Binding InnerId}" />
                    <GridViewColumn Header="Reply"
                                                DisplayMemberBinding="{Binding InreplyTo}" />
                    <GridViewColumn Header="Posted by"
                                                DisplayMemberBinding="{Binding Username}" />
                    <GridViewColumn Header="Comment"
                                                DisplayMemberBinding="{Binding Text}" />
                </GridView>
            </ListView.View>
        </ListView>

        <TextBlock Grid.Row="7" Grid.ColumnSpan="6" Text="{Binding StatusMessage}" Margin="4" />
    </Grid>
</UserControl>
